﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Student_AddStudent : System.Web.UI.Page
{
    private Client client;
    protected void Page_Load(object sender, EventArgs e)
    {
        txtFirstName.ReadOnly = true;
        txtMiddleName.ReadOnly = true;
        txtLastName.ReadOnly = true;
        txtGender.ReadOnly = true;
        txtAddress.ReadOnly = true;
        txtResidency.ReadOnly = true;
        txtContactNo.ReadOnly = true;
        txtProgramCode.ReadOnly = true;
        txtMajorCode.ReadOnly = true;
        txtScholarship.ReadOnly = true;
        txtCollege.ReadOnly = true;
        txtCollege.Enabled = true;
        txtFirstName.Enabled = false;
        txtMiddleName.Enabled = false;
        txtLastName.Enabled = false;
        txtGender.Enabled = false;
        txtAddress.Enabled = false;
        txtResidency.Enabled = false;
        txtContactNo.Enabled = false;
        txtProgramCode.Enabled = false;
        txtMajorCode.Enabled = false;
        txtScholarship.Enabled = false;
    }


    protected void btnViewStudent_Click(object sender, EventArgs e)
    {
        client = new Client();
        Student student = client.ViewStudent(System.Convert.ToInt32(txtStudentId.Text));
        txtResidency.Text = student.getResidency();
        txtFirstName.Text = student.getFirstName();
        txtMiddleName.Text = student.getMiddleName();
        txtLastName.Text = student.getLastName();
        txtCollege.Text = student.getCollege();
        txtGender.Text = student.getGender();
        txtAddress.Text = student.getAddress();
        txtContactNo.Text = student.getContactNo().ToString();
        txtProgramCode.Text = student.getProgramCode();
        txtMajorCode.Text = student.getMajorCode();
        txtScholarship.Text = student.getScholarship();
        
        if (student.getFirstName() != null)
            Response.Write("Successfully Viewed Student " + txtStudentId.Text);
        else
            Response.Write("Please Try Again..");
    }

    protected void btnClear_Click(object sender, EventArgs e)
    {
        Response.Redirect("stdViewStudent.aspx");
    }
};